<{extends file="../layout/layout.phtml"}>
<{block name='content'}>
<link rel="stylesheet" href="/css/admin_ad.css">
<div id='admin-ad-list'>
	<table class="show_table" cellspacing=0 cellspacing=0>
		<tr>
			<th>序号</th>
			<th>标题</th>
			<th>链接地址</th>
			<th>位置</th>
			<th>广告图片</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
		<{foreach $ad_list as $ad}>
		<tr>
			<td><{$ad@index + 1}></td>
			<td><{$ad.title}></td>
			<td><{$ad.href}></td>
			<td><{$ad.adtype_name}></td>
			<td> <img src="/upload/ad/<{$ad.pic}>"></td>
			<td><{if $ad.status == 1}> <font style="color:green">正常</font> <{else}> <font style="color:#DBEAF9">已隐藏</font> <{/if}></td>
			<td><a href="javascript:void(0);" class='delete_a' data=<{$ad._id}> >删除</a></td>
		</tr>
		<{/foreach}>
	</table>
</div>
<script>
	window.addEvent('domready',function(){
		//登陆ajax
	    var product_delete_request = new Request.JSON({
	        url: '/index.php/admin/ad/ajax_addel',
	        method: 'get',
	        onRequest: function(){
	        },
	        onSuccess: function(responseJson){
	            if(responseJson.flag){
	                $$("a[data="+responseJson.msg+"]").getParent('tr').set('styles',{'display':'none'})
	            }
	        },
	        onFailure: function(){
	            alert('Sorry, your request failed :(');
	        }
	    }); 
	    // and to send it:
	    $$(".delete_a").addEvent('click',function(){
	    	if(window.confirm('确定删除吗?')){
	    		$_id = $(this).get('data');
	        	product_delete_request.send("_id="+$_id);
	    	}
	        
	    })
	})
</script>
<{/block}>